package com.xfpp.javaDemo.strategy;

public class Dog implements Comparable{
	private int height;
	
	public Dog(int height) {
		super();
		this.height = height;
	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.height = height;
	}
	
	@Override
	public String toString() {
		return height + "|";
	}

	@Override
	public int compareTo(Object o) {
		try {
			if(o instanceof Dog) {
				Dog d = (Dog)o;
				if(this.getHeight() > d.getHeight()) {
					return 1;
				}else if(this.getHeight() < d.getHeight()) {
					return -1;
				}else {
					return 0;
				}
			}else {
				return -100;
			}
		}catch(Exception e) {
			return -100; 
		}
	}
}
